package com.example.leetdemo.process;

import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;

public class Solution2418 {

    public String[] sortPeople(String[] names, int[] heights) {
        Map<Integer, String> map = new HashMap<>();
        for (int i = 0; i < names.length; i++) {
            map.put(heights[i], names[i]);
        }
        Arrays.sort(heights);
        String[] arr = new String[names.length];
        for (int i = heights.length; i > 0; i--) {
            arr[heights.length - i] = map.get(heights[i - 1]);
        }
        return arr;
    }

}
